using MemoryPack;
using Voxels;

namespace Game {
	[MemoryPackable]
	public sealed partial class BlockItem : BaseInventoryItem<BlockItem> {
		public BlockData BlockData;

		public BlockItem() {
			ItemType = InventoryItemType.Block;
		}

		public override string ItemName {
			get {
				if ( _nameString== null ) {
					_nameString = $"block:{BlockData.Type}";
				}
				return _nameString;
			}
		}

		public override bool IsEqualKind(BaseInventoryItem item) {
			if (  !base.IsEqualKind(item) ) {
				return false;
			}
			var cast = (BlockItem)item;
			if ( cast == null ) {
				return false;
			}

			return cast.BlockData.EqualsExcludeLightAndColor(BlockData);
		}

		protected override BlockItem CreateCopy(int count) {
			var copy = base.CreateCopy(count);
			copy.BlockData = BlockData;
			return copy;

		}
	}
}